<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>社交网站弹出分享操作表单</title>
    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    
    <style>
        :root {
            --primary: #4F46E5;
            --facebook: #1877F2;
            --twitter: #1DA1F2;
            --instagram: #E4405F;
            --whatsapp: #25D366;
            --telegram: #0088CC;
            --linkedin: #0077B5;
            --pinterest: #BD081C;
            --gray: #6B7280;
            --light-gray: #F3F4F6;
            --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            --radius: 10px;
        }
        
        body {
            font-family: 'Inter', system-ui, sans-serif;
            padding: 2rem;
            background-color: #F9FAFB;
        }
        
        .container {
            max-width: 800px;
        }
        
        .card {
            border: none;
            border-radius: var(--radius);
            box-shadow: var(--shadow);
            overflow: hidden;
        }
        
        /* 帖子样式 */
        .post-header {
            display: flex;
            align-items: center;
            padding: 1.25rem;
            gap: 1rem;
        }
        
        .user-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            object-fit: cover;
        }
        
        .user-info {
            flex: 1;
        }
        
        .user-name {
            font-weight: 600;
            margin-bottom: 0;
        }
        
        .post-time {
            font-size: 0.85rem;
            color: var(--gray);
        }
        
        .post-content {
            padding: 0 1.25rem 1rem;
        }
        
        .post-image {
            width: 100%;
            height: 300px;
            object-fit: cover;
            margin-bottom: 1rem;
        }
        
        .post-text {
            margin-bottom: 1rem;
            line-height: 1.6;
        }
        
        .post-actions {
            display: flex;
            border-top: 1px solid var(--light-gray);
            border-bottom: 1px solid var(--light-gray);
        }
        
        .action-btn {
            flex: 1;
            padding: 0.75rem;
            background: none;
            border: none;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
            color: var(--gray);
            font-weight: 500;
            transition: all 0.2s ease;
        }
        
        .action-btn:hover {
            background-color: var(--light-gray);
            color: var(--primary);
        }
        
        .action-btn i {
            font-size: 1.1rem;
        }
        
        /* 分享弹窗样式 */
        .share-backdrop {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            display: flex;
            align-items: flex-end;
            justify-content: center;
            z-index: 1050;
            opacity: 0;
            visibility: hidden;
            transition: all 0.3s ease;
        }
        
        .share-backdrop.active {
            opacity: 1;
            visibility: visible;
        }
        
        .share-modal {
            background-color: white;
            width: 100%;
            max-width: 600px;
            border-radius: var(--radius) var(--radius) 0 0;
            padding: 1.5rem;
            transform: translateY(100%);
            transition: transform 0.3s ease;
            max-height: 90vh;
            overflow-y: auto;
        }
        
        .share-backdrop.active .share-modal {
            transform: translateY(0);
        }
        
        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1.5rem;
        }
        
        .modal-title {
            font-size: 1.25rem;
            font-weight: 600;
            margin: 0;
        }
        
        .close-btn {
            background: none;
            border: none;
            font-size: 1.5rem;
            color: var(--gray);
            cursor: pointer;
        }
        
        /* 分享表单样式 */
        .share-form-group {
            margin-bottom: 1.5rem;
        }
        
        .form-label {
            display: block;
            font-weight: 500;
            margin-bottom: 0.75rem;
            color: var(--dark);
        }
        
        .share-textarea {
            width: 100%;
            padding: 0.75rem;
            border: 1px solid #ddd;
            border-radius: var(--radius);
            min-height: 100px;
            resize: vertical;
            font-family: inherit;
            transition: border-color 0.2s ease;
        }
        
        .share-textarea:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
        }
        
        .char-count {
            text-align: right;
            font-size: 0.85rem;
            color: var(--gray);
            margin-top: 0.5rem;
        }
        
        .share-options {
            margin-bottom: 1.5rem;
        }
        
        .option-title {
            font-size: 0.85rem;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            color: var(--gray);
            margin-bottom: 1rem;
            font-weight: 500;
        }
        
        .social-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 1rem;
        }
        
        .social-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 1rem 0.5rem;
            border-radius: var(--radius);
            transition: all 0.2s ease;
            cursor: pointer;
            position: relative;
        }
        
        .social-item.selected::after {
            content: '';
            position: absolute;
            bottom: 5px;
            width: 5px;
            height: 5px;
            border-radius: 50%;
            background-color: var(--success);
        }
        
        .social-item:hover {
            background-color: var(--light-gray);
        }
        
        .social-icon {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 0.5rem;
            color: white;
            font-size: 1.25rem;
        }
        
        .social-name {
            font-size: 0.85rem;
            font-weight: 500;
        }
        
        .link-share {
            background-color: var(--light-gray);
            border-radius: var(--radius);
            padding: 1rem;
            display: flex;
            align-items: center;
            gap: 1rem;
            margin-bottom: 1.5rem;
        }
        
        .link-input {
            flex: 1;
            background: transparent;
            border: none;
            outline: none;
            font-size: 0.9rem;
            color: var(--gray);
        }
        
        .copy-btn {
            background-color: var(--primary);
            color: white;
            border: none;
            border-radius: 6px;
            padding: 0.5rem 1rem;
            font-weight: 500;
            font-size: 0.9rem;
            transition: all 0.2s ease;
        }
        
        .copy-btn:hover {
            background-color: #4338CA;
        }
        
        .copy-btn.copied {
            background-color: #10B981;
        }
        
        .privacy-options {
            margin-bottom: 1.5rem;
        }
        
        .privacy-radios {
            display: flex;
            gap: 1rem;
            flex-wrap: wrap;
        }
        
        .privacy-option {
            flex: 1;
            min-width: 120px;
        }
        
        .privacy-option input {
            display: none;
        }
        
        .privacy-option label {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.75rem;
            border: 1px solid #ddd;
            border-radius: var(--radius);
            cursor: pointer;
            transition: all 0.2s ease;
            text-align: center;
            justify-content: center;
        }
        
        .privacy-option input:checked + label {
            border-color: var(--primary);
            background-color: rgba(79, 70, 229, 0.05);
            font-weight: 500;
        }
        
        .more-options {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 0.75rem;
            margin-bottom: 1.5rem;
        }
        
        .more-item {
            display: flex;
            align-items: center;
            gap: 1rem;
            padding: 1rem;
            background-color: var(--light-gray);
            border-radius: var(--radius);
            cursor: pointer;
            transition: all 0.2s ease;
        }
        
        .more-item:hover {
            background-color: #E5E7EB;
        }
        
        .more-icon {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background-color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--primary);
        }
        
        .more-text {
            font-weight: 500;
        }
        
        .action-buttons {
            display: flex;
            gap: 1rem;
            margin-top: 1.5rem;
        }
        
        .cancel-btn {
            flex: 1;
            padding: 1rem;
            background-color: white;
            border: 1px solid var(--light-gray);
            border-radius: var(--radius);
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
        }
        
        .cancel-btn:hover {
            background-color: var(--light-gray);
        }
        
        .share-confirm-btn {
            flex: 1;
            padding: 1rem;
            background-color: var(--primary);
            color: white;
            border: none;
            border-radius: var(--radius);
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
        }
        
        .share-confirm-btn:hover {
            background-color: #4338CA;
        }
        
        .share-confirm-btn:disabled {
            background-color: var(--gray);
            cursor: not-allowed;
        }
        
      
        /* 预览区域 */
        .share-preview {
            background-color: var(--light-gray);
            border-radius: var(--radius);
            padding: 1rem;
            margin-bottom: 1.5rem;
        }
        
        .preview-title {
            font-weight: 500;
            margin-bottom: 0.75rem;
            font-size: 0.9rem;
            color: var(--gray);
        }
        
        .preview-content {
            background-color: white;
            border-radius: 8px;
            padding: 1rem;
            font-size: 0.9rem;
            border: 1px solid #eee;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="card">
            <!-- 帖子内容 -->
            <div class="post-header">
                <img src="https://picsum.photos/id/64/40/40" alt="用户头像" class="user-avatar">
                <div class="user-info">
                    <p class="user-name">李明</p>
                    <p class="post-time">今天 14:30</p>
                </div>
            </div>
            
            <div class="post-content">
                <p class="post-text">刚刚发现了一个超棒的新功能，迫不及待想和大家分享！这个工具真的帮我省了很多时间，强烈推荐给大家～</p>
                <img src="https://picsum.photos/id/26/800/300" alt="帖子图片" class="post-image">
            </div>
            
            <!-- 操作按钮 -->
            <div class="post-actions">
                <button class="action-btn like-btn">
                    <i class="far fa-heart"></i>
                    <span>点赞</span>
                </button>
                <button class="action-btn comment-btn">
                    <i class="far fa-comment"></i>
                    <span>评论</span>
                </button>
                <button class="action-btn share-btn" id="shareBtn">
                    <i class="far fa-share-square"></i>
                    <span>分享</span>
                </button>
                <button class="action-btn save-btn">
                    <i class="far fa-bookmark"></i>
                    <span>收藏</span>
                </button>
            </div>
        </div>
    </div>
    
    <!-- 分享弹窗表单 -->
    <div class="share-backdrop" id="shareModal">
        <div class="share-modal">
            <div class="modal-header">
                <h3 class="modal-title">分享到</h3>
                <button class="close-btn" id="closeModal">&times;</button>
            </div>
            
            <!-- 分享表单 -->
            <form id="shareForm">
                <!-- 自定义分享内容 -->
                <div class="share-form-group">
                    <label for="shareComment" class="form-label">添加你的想法（可选）</label>
                    <textarea id="shareComment" class="share-textarea" placeholder="分享时添加一些评论..."></textarea>
                    <div class="char-count"><span id="charCount">0</span>/200</div>
                </div>
                
                <!-- 分享预览 -->
                <div class="share-preview">
                    <div class="preview-title">分享预览</div>
                    <div class="preview-content" id="sharePreview">
                        <p id="previewText">刚刚发现了一个超棒的新功能，迫不及待想和大家分享！这个工具真的帮我省了很多时间，强烈推荐给大家～</p>
                        <p class="text-muted mt-2">https://social.example.com/post/123456</p>
                    </div>
                </div>
                
                <!-- 隐私设置 -->
                <div class="share-form-group privacy-options">
                    <label class="form-label">分享可见性</label>
                    <div class="privacy-radios">
                        <div class="privacy-option">
                            <input type="radio" name="privacy" id="public" value="public" checked>
                            <label for="public">
                                <i class="fas fa-globe-americas"></i>
                                <span>公开</span>
                            </label>
                        </div>
                        <div class="privacy-option">
                            <input type="radio" name="privacy" id="friends" value="friends">
                            <label for="friends">
                                <i class="fas fa-users"></i>
                                <span>仅好友</span>
                            </label>
                        </div>
                        <div class="privacy-option">
                            <input type="radio" name="privacy" id="private" value="private">
                            <label for="private">
                                <i class="fas fa-lock"></i>
                                <span>仅自己</span>
                            </label>
                        </div>
                    </div>
                </div>
                
                <!-- 社交媒体选项 -->
                <div class="share-options">
                    <p class="option-title">分享到社交媒体</p>
                    <div class="social-grid">
                        <div class="social-item" data-platform="facebook">
                            <div class="social-icon" style="background-color: var(--facebook);">
                                <i class="fab fa-facebook-f"></i>
                            </div>
                            <span class="social-name">Facebook</span>
                        </div>
                        <div class="social-item" data-platform="twitter">
                            <div class="social-icon" style="background-color: var(--twitter);">
                                <i class="fab fa-twitter"></i>
                            </div>
                            <span class="social-name">Twitter</span>
                        </div>
                        <div class="social-item" data-platform="instagram">
                            <div class="social-icon" style="background-color: var(--instagram);">
                                <i class="fab fa-instagram"></i>
                            </div>
                            <span class="social-name">Instagram</span>
                        </div>
                        <div class="social-item" data-platform="whatsapp">
                            <div class="social-icon" style="background-color: var(--whatsapp);">
                                <i class="fab fa-whatsapp"></i>
                            </div>
                            <span class="social-name">WhatsApp</span>
                        </div>
                        <div class="social-item" data-platform="telegram">
                            <div class="social-icon" style="background-color: var(--telegram);">
                                <i class="fab fa-telegram-plane"></i>
                            </div>
                            <span class="social-name">Telegram</span>
                        </div>
                        <div class="social-item" data-platform="linkedin">
                            <div class="social-icon" style="background-color: var(--linkedin);">
                                <i class="fab fa-linkedin-in"></i>
                            </div>
                            <span class="social-name">LinkedIn</span>
                        </div>
                        <div class="social-item" data-platform="pinterest">
                            <div class="social-icon" style="background-color: var(--pinterest);">
                                <i class="fab fa-pinterest-p"></i>
                            </div>
                            <span class="social-name">Pinterest</span>
                        </div>
                        <div class="social-item" data-platform="more">
                            <div class="social-icon" style="background-color: var(--gray);">
                                <i class="fas fa-ellipsis-h"></i>
                            </div>
                            <span class="social-name">更多</span>
                        </div>
                    </div>
                </div>
                
                <!-- 链接分享 -->
                <div class="link-share">
                    <input type="text" value="https://social.example.com/post/123456" class="link-input" readonly>
                    <button type="button" class="copy-btn" id="copyLinkBtn">复制链接</button>
                </div>
                
                <!-- 其他分享方式 -->
                <div class="share-options">
                    <p class="option-title">其他分享方式</p>
                    <div class="more-options">
                        <div class="more-item" data-action="messenger">
                            <div class="more-icon">
                                <i class="far fa-paper-plane"></i>
                            </div>
                            <span class="more-text">发送给好友</span>
                        </div>
                        <div class="more-item" data-action="group">
                            <div class="more-icon">
                                <i class="fas fa-users"></i>
                            </div>
                            <span class="more-text">分享到群组</span>
                        </div>
                        <div class="more-item" data-action="email">
                            <div class="more-icon">
                                <i class="far fa-envelope"></i>
                            </div>
                            <span class="more-text">通过邮件分享</span>
                        </div>
                        <div class="more-item" data-action="print">
                            <div class="more-icon">
                                <i class="fas fa-print"></i>
                            </div>
                            <span class="more-text">打印</span>
                        </div>
                    </div>
                </div>
                
                <!-- 操作按钮 -->
                <div class="action-buttons">
                    <button type="button" class="cancel-btn" id="cancelBtn">取消</button>
                    <button type="submit" class="share-confirm-btn" id="confirmShareBtn">
                        <i class="fas fa-share"></i>
                        <span>确认分享</span>
                    </button>
                </div>
            </form>
        </div>
    </div>
    


    <!-- Bootstrap 5 JS Bundle with Popper -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // 获取DOM元素
            const shareBtn = document.getElementById('shareBtn');
            const shareModal = document.getElementById('shareModal');
            const closeModal = document.getElementById('closeModal');
            const cancelBtn = document.getElementById('cancelBtn');
            const copyLinkBtn = document.getElementById('copyLinkBtn');
            const toastNotification = document.getElementById('toastNotification');
            const socialItems = document.querySelectorAll('.social-item');
            const moreItems = document.querySelectorAll('.more-item');
            const shareForm = document.getElementById('shareForm');
            const shareComment = document.getElementById('shareComment');
            const charCount = document.getElementById('charCount');
            const sharePreview = document.getElementById('previewText');
            const confirmShareBtn = document.getElementById('confirmShareBtn');
            
            // 选中的平台
            let selectedPlatforms = [];
            
            // 打开分享弹窗
            shareBtn.addEventListener('click', function() {
                shareModal.classList.add('active');
                document.body.style.overflow = 'hidden'; // 防止背景滚动
                // 重置表单
                resetForm();
            });
            
            // 关闭分享弹窗
            function closeShareModal() {
                shareModal.classList.remove('active');
                document.body.style.overflow = ''; // 恢复背景滚动
            }
            
            closeModal.addEventListener('click', closeShareModal);
            cancelBtn.addEventListener('click', closeShareModal);
            
            // 点击弹窗外部关闭
            shareModal.addEventListener('click', function(e) {
                if (e.target === shareModal) {
                    closeShareModal();
                }
            });
            
            // 字符计数
            shareComment.addEventListener('input', function() {
                const count = this.value.length;
                charCount.textContent = count;
                
                // 限制最大字符数
                if (count > 200) {
                    this.value = this.value.substring(0, 200);
                    charCount.textContent = 200;
                }
                
                // 更新预览
                updatePreview();
            });
            
            // 更新预览
            function updatePreview() {
                const originalText = "刚刚发现了一个超棒的新功能，迫不及待想和大家分享！这个工具真的帮我省了很多时间，强烈推荐给大家～";
                if (shareComment.value.trim()) {
                    sharePreview.innerHTML = `
                        <p>${shareComment.value}</p>
                        <p class="text-muted">${originalText.substring(0, 30)}...</p>
                        <p class="text-muted mt-2">https://social.example.com/post/123456</p>
                    `;
                } else {
                    sharePreview.innerHTML = `
                        <p>${originalText}</p>
                        <p class="text-muted mt-2">https://social.example.com/post/123456</p>
                    `;
                }
            }
            
            // 复制链接功能
            copyLinkBtn.addEventListener('click', function() {
                const linkInput = document.querySelector('.link-input');
                linkInput.select();
                navigator.clipboard.writeText(linkInput.value).then(() => {
                    // 显示已复制状态
                    copyLinkBtn.textContent = '已复制';
                    copyLinkBtn.classList.add('copied');
                    
                    // 显示提示
                    showToast('链接已复制到剪贴板');
                    
                    // 恢复按钮状态
                    setTimeout(() => {
                        copyLinkBtn.textContent = '复制链接';
                        copyLinkBtn.classList.remove('copied');
                    }, 2000);
                });
            });
            
            // 社交媒体选择
            socialItems.forEach(item => {
                item.addEventListener('click', function() {
                    const platform = this.getAttribute('data-platform');
                    const index = selectedPlatforms.indexOf(platform);
                    
                    // 切换选择状态
                    if (index === -1) {
                        selectedPlatforms.push(platform);
                        this.classList.add('selected');
                    } else {
                        selectedPlatforms.splice(index, 1);
                        this.classList.remove('selected');
                    }
                    
                    // 更新确认按钮状态
                    updateConfirmButton();
                });
            });
            
            // 其他分享方式
            moreItems.forEach(item => {
                item.addEventListener('click', function() {
                    const action = this.getAttribute('data-action');
                    const actionText = this.querySelector('.more-text').textContent;
                    
                    // 模拟分享操作
                    simulateShare('other', actionText);
                });
            });
            
            // 更新确认按钮状态
            function updateConfirmButton() {
                confirmShareBtn.disabled = selectedPlatforms.length === 0;
            }
            
            // 表单提交
            shareForm.addEventListener('submit', function(e) {
                e.preventDefault();
                
                if (selectedPlatforms.length === 0) {
                    showToast('请选择至少一个分享平台', false);
                    return;
                }
                
                // 获取选中的平台名称
                const platformNames = selectedPlatforms.map(platform => {
                    const item = document.querySelector(`.social-item[data-platform="${platform}"]`);
                    return item ? item.querySelector('.social-name').textContent : platform;
                }).join('、');
                
                // 模拟分享操作
                simulateShare('social', platformNames);
            });
            
            // 模拟分享功能
            function simulateShare(type, name) {
                // 在实际应用中，这里会调用相应的分享API
                console.log(`分享到 ${name}`);
                
                // 关闭弹窗
                closeShareModal();
                
                // 显示成功提示
                showToast(`内容已成功分享到 ${name}`);
            }
            
        
            
            // 重置表单
            function resetForm() {
                shareComment.value = '';
                charCount.textContent = '0';
                selectedPlatforms = [];
                socialItems.forEach(item => item.classList.remove('selected'));
                document.getElementById('public').checked = true;
                updatePreview();
                updateConfirmButton();
            }
            
            // 其他交互效果 - 点赞、评论、收藏按钮
            const likeBtn = document.querySelector('.like-btn');
            const commentBtn = document.querySelector('.comment-btn');
            const saveBtn = document.querySelector('.save-btn');
            
            likeBtn.addEventListener('click', function() {
                const icon = this.querySelector('i');
                if (icon.classList.contains('far')) {
                    icon.classList.remove('far');
                    icon.classList.add('fas', 'text-danger');
                    this.querySelector('span').textContent = '已点赞';
                } else {
                    icon.classList.remove('fas', 'text-danger');
                    icon.classList.add('far');
                    this.querySelector('span').textContent = '点赞';
                }
            });
            
            saveBtn.addEventListener('click', function() {
                const icon = this.querySelector('i');
                if (icon.classList.contains('far')) {
                    icon.classList.remove('far');
                    icon.classList.add('fas', 'text-primary');
                    this.querySelector('span').textContent = '已收藏';
                } else {
                    icon.classList.remove('fas', 'text-primary');
                    icon.classList.add('far');
                    this.querySelector('span').textContent = '收藏';
                }
            });
            
            commentBtn.addEventListener('click', function() {
                showToast('打开评论区');
            });
            
            // 初始化预览
            updatePreview();
            updateConfirmButton();
        });
    </script>
</body>
</html>
    
